package Opgave2;

public class JobConsumer implements Runnable {

	PrintQueue queue;
	Boolean working = true;

	public JobConsumer(PrintQueue queue) {
		this.queue = queue;
	}
	
	public void run() {
		synchronized(queue) {		
			while(working) {
				while(queue.size() == 0) {
					try {
						queue.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				} 
				System.out.println(queue.removeJob());
				queue.notifyAll();
			}
		}
	}
}